Schizophrenia (object-oriented Programming)
   HOME

TheInfoList



OR:

Object schizophrenia or self schizophrenia is a complication arising from delegation and related techniques in
object-oriented programming Object-oriented programming (OOP) is a programming paradigm based on the concept of "objects", which can contain data and code. The data is in the form of fields (often known as attributes or ''properties''), and the code is in the form of pr ...
, where self/this can refer to more than one object. By way of metaphor with the public confusion of
dissociative identity disorder Dissociative identity disorder (DID), better known as multiple personality disorder or multiple personality syndrome, is a mental disorder characterized by the presence of at least two distinct and relatively enduring personality states. The di ...
with the psychiatric diagnosis of
schizophrenia Schizophrenia is a mental disorder characterized by continuous or relapsing episodes of psychosis. Major symptoms include hallucinations (typically hearing voices), delusions, and disorganized thinking. Other symptoms include social withdra ...
, the former being associated with "split personalities," this configuration is called ''object schizophrenia'' or ''self schizophrenia'' in object-oriented programming.


Overview

An
object Object may refer to: General meanings * Object (philosophy), a thing, being, or concept ** Object (abstract), an object which does not exist at any particular time or place ** Physical object, an identifiable collection of matter * Goal, an ...
can be defined as a computing concept combining data and behavior, and having an identity. In
class-based programming Class-based programming, or more commonly class-orientation, is a style of object-oriented programming (OOP) in which inheritance occurs via defining ''classes'' of objects, instead of inheritance occurring via the objects alone (compare prototy ...
, objects are built on class systems, where an object is an instance of a class. Classes can in turn be related by
inheritance Inheritance is the practice of receiving private property, Title (property), titles, debts, entitlements, Privilege (law), privileges, rights, and Law of obligations, obligations upon the death of an individual. The rules of inheritance differ ...
: a ''base class'' provides the fundamental or default behavior of an object, and acts as a template for creating objects, while a ''derived class'' can be used to override behaviors of a base class, and can be used as a template for objects whose behaviors refine those of the base class. An alternative to classes and inheritance is prototypes and delegation, which is used in
prototype-based programming Prototype-based programming is a style of object-oriented programming in which behaviour reuse (known as inheritance) is performed via a process of reusing existing objects that serve as prototypes. This model can also be known as ''prototypa ...
, and is more dynamic. Instead of using one class to refine another, delegation allows one object to override the behavior of another. The original object ''a'' (analogous to the derived class behaviors) can ''delegate'' some of its methods to another object ''b'' (analogous to the base class behaviors). If ''a'' delegates its ''foo'' method to the ''bar'' method of ''b'', then any invocation of ''foo'' on ''a'' will cause ''bs ''bar'' method to execute. However, ''bar'' executes in the context of the ''a'' object, for example, its self identifier refers to ''a'' rather than to ''b''. When delegation is used, the question arises: What is the value of self when evaluating a method on object ''a'', which is delegated to a method on object ''b''? The identity is split: it can refer to ''a'' or ''b''. Note that while the two objects are separate and have separate physical identity, self (whether used explicitly or implicitly) is ambiguous.


History and discussion

HerrmannStephan Herrmann,
Demystifying Object Schizophrenia
', in Proceedings o
MASPEGHI Workshop
a
ECOOP 2010
/ref> reports that the term was coined by William Harrison, IBM Research, around May 1997 in a set of web pages, which discussed problems incurred by some of the common
design pattern A design pattern is the re-usable form of a solution to a design problem. The idea was introduced by the architect Christopher Alexander and has been adapted for various other disciplines, particularly software engineering. The " Gang of Four" b ...
s (these web pages are no longer publicly available). In the given examples the problem was aggravated by the fact that typical solutions would use a weaker form of delegation (sometimes called forwarding) where knowledge about the original receiver object is actually lost during delegation. Here the use of forwarding is owed to the fact that most mainstream
object-oriented programming languages Object-oriented programming (OOP) is a programming paradigm based on the concept of "objects", which can contain data and code. The data is in the form of fields (often known as attributes or ''properties''), and the code is in the form of pro ...
do not support the stronger form of delegation. Harrison et al proposed subject-oriented programming as a solution, which by static composition avoids any issues of object schizophrenia. On the other end of the spectrum, Herrmann shows that a language featuring contextual
roles A role (also rĂ´le or social role) is a set of connected behaviors, rights, obligations, beliefs, and norms as conceptualized by people in a social situation. It is an expected or free or continuously changing behavior and may have a given indiv ...
can be designed in such a way that potential problems of object schizophrenia are essentially irrelevant despite using delegation as a means to share behavior between a ''role object'' and its associated ''base object''.


See also

*


References

{{DEFAULTSORT:Schizophrenia (Object-Oriented Programming) Object-oriented programming Prototype-based programming